package com.gupaoedu.dubbo;

/**
 * <p>
 *
 * </p>
 *
 * @author Nicky
 * @since 2019-07-17
 */
public class TestMain {

    public Boolean tryLock(long timeOut) {

        Long endTime = System.currentTimeMillis() + timeOut;

        while (true) {
            endTime = endTime - timeOut;
            if (endTime < 0) {
                System.out.println("true");
                return true;
            } else {
                System.out.println("false");
                return false;
            }
        }
    }

    public void tryWhile(int k) {
        while (true) {
            boolean s = false;
            for (int i = 0; i < 20; i++) {
                if (k == i) {
                    System.out.println(i);
                    s=true;
                    break;
                }
            }

            if(s){
                break;
            }

        }
    }


    public static void main(String[] args) {
//        while (true) {
//            System.out.println("执行");
//            if (true) {
//                break;
//            }
//            System.out.println("继续执行 ");
//        }
        TestMain testMain = new TestMain();

        testMain.tryWhile(5);
    }

}
